package com.gxa.ticket.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;

import dto.ResultDTO;
import entity.Flight;

import com.gxa.ticket.param.FlightParam;
import com.gxa.ticket.service.FlightService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import dto.ResultDTO;


import entity.Flight;
import entity.MacOrder;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;

/**
 * 航班表(Flight)表控制层
 *
 * @author makejava
 * @since 2021-05-10 18:44:35
 */
@RestController
@RequestMapping("ticket")
@Api(tags = "航班相关的接口")
public class FlightController {
    /**
     * 服务对象
     */
    @Resource
    private FlightService flightService;

    /**
     * 查询所有航空公司
     * @return
     */
    @ApiOperation(value = "查询所有航空公司")
    @PostMapping("/find/all/airline")
    public ResultDTO findAllAirline(){
        return flightService.findAllAirline();
    }


    @ApiOperation(value = "查询城市")
    @PostMapping("/find/city")
    public ResultDTO findAllCity(){
        return flightService.findCity();
    }








//    /**
//     * 公司筛选
//     * @param airportIds
//     * @return
//     */
//    @ApiOperation(value = "公司筛选")
//    @ApiImplicitParam(name = "airportIds", value = "所选公司ID的数组", required = true)
//    @PostMapping("airport/screen")
//    public ResultDTO findByAirportSet(Integer[] airportIds){
//        return flightService.findByAirport(airportIds);
//    }

//    /**
//     * 出发时间筛选
//     * @param timeIds
//     * @return
//     */
//    @ApiOperation(value = "出发时间筛选")
//    @ApiImplicitParam(name = "timeIds", value = "所选起始时间ID的数组", required = true)
//    @PostMapping("start-time/screen")
//    public ResultDTO findByStartTimeSet(Integer[] timeIds){
//        return flightService.findByStartTime(timeIds);
//    }


    /**
     * 出发时间升序
     * @return
     */
    @ApiOperation(value = "出发时间升序")
    @PostMapping("start-time/asc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO startTimeAsc(@RequestBody FlightParam flightParam){
        return flightService.startTimeAsc(flightParam);
    }

    /**
     * 根据条件查询航班
     * @param flightParam
     * @return
     */
    @ApiOperation(value = "根据条件查询航班")
    @PostMapping("/get/all")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO findByCondition(@RequestBody FlightParam flightParam){
        return flightService.findByCondition(flightParam);
    }

    /**
     * 随机查询航班
     * @return
     */
    @ApiOperation(value = "随机查询航班")
    @PostMapping("/get/all-flight1")
    public ResultDTO findAll(){
        return flightService.findAllFlight();
    }

    /**
     * 根据机票id 查询机票是否存在
     * @param flightId
     * @return
     */
    @PostMapping("/get/byFlightId")
    public ResultDTO findByFlightId(@RequestBody Integer flightId){
        return flightService.findByFlightId(flightId);
    }

    /**
     * 根据机票id 查询座位库存是否大于0
     * @param flightId
     * @return
     */
    @PostMapping("get/count")
    public ResultDTO selectCount(@RequestBody Integer flightId){
        return flightService.selectCount(flightId);
    }

    /**
     * 查id集合查询机票信息
     * @param orderList
     * @return
     */
    @PostMapping("get/list")
    public ResultDTO findByFlightIdList(@RequestBody List<MacOrder> orderList){
        return flightService.findByFlightId(orderList);
    }
    /**
     * 出发时间降序
     * @return
     */
    @ApiOperation(value = "出发时间降序")
    @PostMapping("start-time/desc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO startTimeDesc(@RequestBody FlightParam flightParam){
        return flightService.startTimeDesc(flightParam);
    }

    /**
     * 降落时间升序
     * @return
     */
    @ApiOperation(value = "降落时间升序")
    @PostMapping("end-time/asc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO endTimeAsc(@RequestBody FlightParam flightParam){
        return flightService.endTimeAsc(flightParam);
    }

    /**
     * 降落时间降序
     * @return
     */
    @ApiOperation(value = "降落时间降序")
    @PostMapping("end-time/desc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO endTimeDesc(@RequestBody FlightParam flightParam){
        return flightService.endTimeDesc(flightParam);
    }

    /**
     * 航班时长
     * @return
     */
    @ApiOperation(value = "航班时长升序")
    @PostMapping("/get/total/time/asc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO totalTimeAsc(@RequestBody FlightParam flightParam){
        return flightService.totalTimeAsc(flightParam);
    }

    /**
     * 航班时长
     * @param flightParam
     * @return
     */
    @ApiOperation(value = "航班时长降序")
    @PostMapping("/get/total/time/desc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO totalTimeDesc(@RequestBody FlightParam flightParam){
        return flightService.totalTimeDesc(flightParam);
    }

    /**
     * 价格升序
     * @return
     */
    @ApiOperation(value = "价格升序")
    @PostMapping("/get/price/asc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO priceAsc(@RequestBody FlightParam flightParam){
        return flightService.priceAsc(flightParam);
    }

    /**
     * 价格降序
     * @return
     */
    @ApiOperation(value = "价格降序")
    @PostMapping("/get/price/desc")
    @ApiOperationSupport(ignoreParameters = {"startDay1","startDay2"})
    @ApiImplicitParams({
            @ApiImplicitParam(name="flightParam",value="flightParam",required = true),
    })
    public ResultDTO priceDesc(@RequestBody FlightParam flightParam){
        return flightService.priceDesc(flightParam);
    }


    /**
     * 根据数组航班id查询航班信息
     * @param flightIds
     * @return
     */
    @ApiOperation(value = "根据数组查询信息")
    @PostMapping("/select/by/flightIds")
    public ResultDTO findFlightList(@RequestBody Integer[] flightIds){
        return flightService.findFlightList(flightIds);
    }

}
